package com.iotechn.unimall.data.dto.excel;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
import cn.afterturn.easypoi.excel.annotation.ExcelTarget;
import lombok.Data;

import java.io.Serializable;
import java.text.DecimalFormat;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;

/**
 * @author kyms
 * @date 2020-07-27 09:50
 */
@ExcelTarget("distributionDTO")
@Data
public class DistributionDTO implements Serializable {
    @Excel(name = "用户名", needMerge = true)
    private String realname;
    @Excel(name = "卡号", needMerge = true)
    private String cardNo;
    @Excel(name = "昵称", needMerge = true)
    private String nickname;
    @Excel(name = "手机号", needMerge = true,width = 20)
    private String phone;
    @Excel(name = "性别", replace = {"未知性别_-1", "女_1", "男_2", "未知性别_ ", "未知性别_0"}, needMerge = true)
    private Integer gender;
    @Excel(name = "余额(元)", needMerge = true)
    private Float totalBalance;


    @ExcelCollection(name = "充值记录", orderNum = "6")
    private List<DistributionBalanceDetailDTO> chargeLog = new LinkedList<>();
    @ExcelCollection(name = "消费记录", orderNum = "7")
    private List<DistributionBalanceDetailDTO> payLog = new LinkedList<>();
    //详情里信息v 额外字段
    private Integer type;
    private Long userId;
    private String description;
    private Date gmtCreate;
    private Float balance;

    private Long descriptionId;

    public Float getTotalBalance() {
        if (this.totalBalance == null) {
            return 0F;
        }
        DecimalFormat decimalFormat = new DecimalFormat(".00");
        String total = decimalFormat.format((this.totalBalance / 100));
        return Float.valueOf(total);
    }

}
